package com.example.excel.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

/**
 * @author dingfeng
 * @version 1.0
 * @DEC
 * @date 2022-04-01 17:30
 */
@Configuration
public class UploadConfig {

    private final static String MAX_FILE_SIZE = "467000";

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setMaxRequestSize(DataSize.parse(MAX_FILE_SIZE));
        factory.setMaxFileSize(DataSize.parse(MAX_FILE_SIZE));
        return factory.createMultipartConfig();
    }

}
